﻿using System.Threading.Tasks;
using OpenFileTransfer.Wpf.WebSocketServer.Server;
using SuperSocket.Command;
using SuperSocket.ProtoBase;
using SuperSocket.WebSocket.Server;

namespace OpenFileTransfer.Wpf.WebSocketServer.Commands
{
    /// <summary>
    /// 心跳命令
    /// </summary>
    [Command(Key = "Heartbeat")]
    [AsyncKeyUpperCommandFilter]
    public class HeartbeatCommand : IAsyncCommand<WebSocketSession, StringPackageInfo>
    {
        public async ValueTask ExecuteAsync(WebSocketSession session, StringPackageInfo package)
        {
            await Task.CompletedTask;

            //执行心跳
            (session as MySession)?.DoHeartBeat();
        }
    }
}
